package cn.wolfcode.trip.admin.controller;

import cn.wolfcode.trip.base.domain.StrategyCatalog;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.query.StrategyCatalogQueryObject;
import cn.wolfcode.trip.base.service.IRegionService;
import cn.wolfcode.trip.base.service.IStrategyCatalogService;
import cn.wolfcode.trip.base.service.IStrategyService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 大攻略资源管理控制器
 */
@Controller
@RequestMapping("/strategyCatalog")
public class StrategyCatalogController {
    @Autowired
    IStrategyCatalogService strategyCatalogService;
    @Autowired
    IStrategyService strategyService;
    /**
     * 分页
     * @return
     */
    @RequestMapping("/list")
    @ResponseBody
    public String auditquery(@ModelAttribute("qo") StrategyCatalogQueryObject qo, Model model){
        //查询全部大攻略
        model.addAttribute("pageInfo",strategyCatalogService.query(qo));
        model.addAttribute("strategies",strategyService.listAll());
        return "strategyCatalog/list";
    }

    /**
     * 新增和编辑
     * @param strategyCatalog
     * @return
     */
    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public JSONResult saveOrUpdate(StrategyCatalog strategyCatalog){
        strategyCatalogService.saveOrUpdate(strategyCatalog);
        return new JSONResult();
    }
}
